package cn.caojun.auth.service.Impl;

import cn.caojun.auth.domain.Permission;
import cn.caojun.auth.mapper.PermissionMapper;
import cn.caojun.auth.query.PermissionQuery;
import cn.caojun.auth.service.IPermissionService;
import cn.caojun.basic.service.impl.BaseServiceImpl;
import cn.caojun.basic.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionSeviceImpl extends BaseServiceImpl<Permission> implements IPermissionService {

    @Autowired
    PermissionMapper permissionMapper;

    @Override
    public List<Permission> getAll() {
        return permissionMapper.loadAll();
    }

    @Override
    public PageList<Permission> getLimteList(PermissionQuery permissionQuery) {
        Long total=permissionMapper.getSize(permissionQuery);
        if (total>0){
            List<Permission> list=permissionMapper.getDate(permissionQuery);
            return new PageList<>(total,list);
        }
        return new PageList<>();
    }

    @Override
    public List<Permission> getPermissionTree() {
        return permissionMapper.getTree();
    }
}
